<!--
 * @Description: 
 * @Autor: zhangbing
 * @Date: 2021-07-30 16:08:25
 * @LastEditors: zhangbing
 * @LastEditTime: 2021-07-31 15:29:47
-->
h<!--
 * @Description: 
 * @Autor: zhangbing
 * @Date: 2021-07-30 00:14:02
 * @LastEditors: zhangbing
 * @LastEditTime: 2021-07-30 18:46:03
-->

<template>
  <div>
    <home-header></home-header>
    <home-swiper />
    <home-icons />
    <home-recommend />
    <home-weekend />
  </div>
</template>

<script>
import HomeHeader from "./components/Header.vue";
import HomeSwiper from "./components/Swiper.vue";
import HomeIcons from "./components/Icons.vue";
import HomeRecommend from "./components/Recommend.vue";
import HomeWeekend from "./components/Weekend.vue";

import axios from "axios";
import { mapState } from "vuex";

export default {
  name: "Home",
  components: {
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeRecommend,
    HomeWeekend,
  },
  data() {
    return {
      lastCity: '',
    };
  },
  created() {},
  mounted() {
    this.lastCity = this.city;
    this.getHomeInfo();
  },
  computed: {
    ...mapState(["city"]),
  },
  methods: {
    getHomeInfo() {
      axios.get("/api/index.json?city=" + this.city).then(this.getHomeInfoSucc);
    },
    getHomeInfoSucc(res) {
      console.log(res);
    },
  },
  activated() {
    if(this.lastCity !== this.city) {
      this.lastCity = this.city
      this.getHomeInfo()
    }
  },
};
</script>

<style>
</style>

